#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Purpose: Test Renderer
# Created: 04/15/2009
# $Id $
# Copyright (c) 2008,2009 by University College London
# Authors:
# Didrik Pinte --<dpinte@dipole-consulting.com>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with HydroPlatform for details.


import unittest

import support
support.init_hydroplatform()

from hydroplatform.ui.renderer import get_thirdpoint

class Point(object):
    
    def __init__(self, x, y):
        self.x = x
        self.y = y

class TestThirdPoint(unittest.TestCase):
    
    def test_case1(self):
        '''
        (x1,y1) is lower than (x2,y2)
        '''
        p1 = Point(1, 10)
        p2 = Point(5,25)
        
        (x,y) = get_thirdpoint(p1, p2)
        self.assertAlmostEqual(x, 3, 0.5)
        self.assertAlmostEqual(y, 16, 0.5) 
        
    def test_case2(self):
        '''
        y1 > y2
        '''
        p1 = Point(1, 25)
        p2 = Point(5,10)
        
        (x,y) = get_thirdpoint(p1, p2)
        self.assertAlmostEqual(x, 3, 0.5)
        self.assertAlmostEqual(y, 16, 0.5)
        
         
